Linux分配不到IP地址 Device eth0 does not seem to be present, delaying initialization

当我使用命令service network restart的时候,报Device eth0 does not seem to be present, delaying initialization这个错误.

然后我通过ifconfig,拿不到IP地址,显示如下内容,

1
2
3
4
5
6
7
8
lo        Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)

原因是静态IP与旧设备的MAC地址绑定了.解决方案如下:

1 删除旧MAC地址: rm /etc/udev/rules.d/70-persistent-net.rules

2 重启 reboot

3 重启后会自动生成新的MAC地址 ,打开70-persistent-net.rules

1
2
3
4
5
6
7
8
# This file was automatically generated by the /lib/udev/write_net_rules
# program, run by the persistent-net-generator.rules rules file.
#
# You can modify it, as long as you keep each rule on a single
# line, and change only the value of the NAME= key.

# PCI device 0x8086:0x100e (e1000)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="08:00:27:fe:c1:03", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"

记下其中的08:00:27:fe:c1:03MAC地址

4 编辑 /etc/sysconfig/network-scripts/ifcfg-eth0,修改MAC地址,同时删掉UUID这一行

5 重启网络服务service network restart